import MySQLdb
db = MySQLdb.connect("localhost", "root","", "TestDb", charset="utf8")
print('connect success')
cursor = db.cursor()
cursor.execute('SELECT * FROM `plan`')
all = cursor.fetchall()
for row in all:
  id = row[0]
  print('id', id)

db.close()